/*
 * spi.c
 *
 * Created: 14.01.2013 14:33:22
 *  Author: saenko
 */ 
#include <avr/io.h>

#define MOSI 3
#define SCK 5
#define SS 2

void spi_init(void)
{
	DDRB = (1<<MOSI)|(1<<SCK)|(1<<SS);
	SPCR = (1<<SPE)|(1<<MSTR)|(1<<SPR0);
}

unsigned char spi_tx(unsigned char data)
{
	
	SPDR = data;
	while(!(SPSR & (1<<SPIF)));
	return SPDR;
}